#include "trap.h"
#include "basic_test.h"
    .set noat
    .globl main
    .data 
    data1: .byte 0x00, 0x00, 0x00, 0x00
    data2: .word 0x00000000
    data3: .half 0x0000, 0x0000
    data4: .word 0x00000000
    .text
main:

    # SB 1
    SB(0xccbb, 0xddaa, data1, 0x0000) # [0x0] = 0xaa
    SB(0x1111, 0x1111, data1, 0x0002) # [0x2] = 0x11
    SB(0x0627, 0x8013, data1, 0x0003) # [0x3] = 0x13
    SB(0x4444, 0x4444, data2, 0x0000) # [0x4] = 0x44
    SB(0x5555, 0x5555, data2, 0x0001) # [0x5] = 0x55
    SB(0x8888, 0x8888, data3, 0x0001) # [0x9] = 0x88
    SB(0x77ff, 0xffff, data3, 0x0003) # [0xb] = 0xff

    # LB 2
    SLB_TEST(data1, 0x0000) # 0xfffffffaa
    SLB_TEST(data1, 0x0002) # 0x000000011
    SLB_TEST(data1, 0x0003) # 0x000000013
    SLB_TEST(data2, 0x0000) # 0x000000044
    SLB_TEST(data2, 0x0001) # 0x000000055
    SLB_TEST(data3, 0x0001) # 0xfffffff88
    SLB_TEST(data3, 0x0003) # 0xfffffffff
    
    # LBU 3
    LBU_TEST(data1, 0x0000) # [0x0] = 0xaa
    LBU_TEST(data1, 0x0002) # [0x2] = 0x11
    LBU_TEST(data1, 0x0005) # [0x5] = 0x55
    LBU_TEST(data2, 0x0005) # [0x9] = 0x88
    LBU_TEST(data3, 0x0003) # [0xb] = 0xff

    # SH 4
    SH(0x3333, 0x2334, data2, 0x0002) # [0x6] = 0x34 [0x7] == 0x23
    SH(0x1212, 0xa256, data4, 0x0000) # [0xc] = 0x56 [0xd] == 0xa2
    SH(0xeeff, 0xbbcc, data1, 0x0000) # [0x0] = 0xcc [0x1] == 0xbb
    
    # LH 5
    SLH_TEST(data1, 0x0002) # 0x00001311
    SLH_TEST(data4, 0x0000) # 0xffffa256
    SLH_TEST(data1, 0x0000) # 0xffffbbcc
    
    # LHU 6
    LHU_TEST(data4, 0x0000) # 0x0000a256
    LHU_TEST(data2, 0x0000) # 0x00005544
    LHU_TEST(data1, 0x0000) # 0x0000bbcc
    
    # SW 7
    SW(0x5678, 0xabcd, data2, 0x0000) # [0x4-0x7] = 0xcdab7856
    SW(0x8000, 0x0000, data3, 0x0000) # [0x8-0xc] = 0x00000080

    # LW 8
    SLW_TEST(data2, 0x0000) # 0x5678abcd
    SLW_TEST(data2, 0x0004) # 0x80000000

    # mix
    SB(0x7fff, 0xffff, data1, 0x0001) # [0x1] = 0xff 
    SH(0x6666, 0x6677, data1, 0x0002) # [0x2] = 0x77 [0x3] = 0x66
    SLW_TEST(data1, 0x0000) # 0x6677ffcc
    SW(0xffff, 0xffff, data3, 0x0004) # [0xc-0xf] = ffffffff
    SLH_TEST(data4, 0x0000) # 0xffffffff
    LHU_TEST(data4, 0x0000) # 0x0000ffff
    SLB_TEST(data3, 0x0003) # 0xffffff80
    LBU_TEST(data3, 0x0003) # 0x00000080
    HIT_GOOD_TRAP		# stop temu